package org.baoping.demo.controller.demo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.baoping.commom.api.CommonPage;
import org.baoping.commom.api.CommonResult;
import org.baoping.demo.domain.entity.admin.SysAdmin;
import org.baoping.demo.mq.MessageProducer;
import org.baoping.demo.service.admin.SysAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author HeZeMin
 * @className DemoController
 * @description
 * @date 2021/1/12 9:54
 */
@Slf4j
@RestController
@RequestMapping("/demo")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class DemoController {
    private final SysAdminService adminService;
    private final MessageProducer messageProducer;

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public CommonResult list(HttpServletRequest request){
        List<SysAdmin> test = adminService.test(1, 10);
        log.info("**********controller 被访问了**************");
        Map<String, Object> paramMap = new HashMap<>();
        paramMap.put("code", "1111111");
        messageProducer.send1(paramMap);
        paramMap.put("code", "22222222");
        messageProducer.send2(paramMap);

        return CommonResult.success(CommonPage.restPage(test));
    }
}